package cn.kgb.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import cn.kgb.javabean.ServicesJob;
import cn.kgb.util.DataAccess;

public class InitServicesJobTimeDAO {
	public List getServicesTime(){
		Connection con = DataAccess.getConnection();
		String sql = "SELECT * FROM myjavamail_services_job_time l order by l.id";
		List list= new ArrayList();
		Statement stmt = null;
		try {
			stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
	         while (rs.next()){
	        	 ServicesJob sj = new ServicesJob();
	        	 sj.setId(rs.getInt("id"));
	        	 sj.setType(rs.getInt("type"));
	        	 sj.setInfo(rs.getString("info"));
	        	 sj.setTime(rs.getString("time"));
	        	 list.add(sj);
	         }
	         rs.close();
	         stmt.close();
	         con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if (stmt != null) {
				try {
					stmt.close();
				} catch (Exception sqlex) {
				}
				stmt = null;
			}
			if (con != null) {
				try {
					con.close();
				} catch (Exception sqlex) {
				}
				con = null;
			}
		}
		return list;
	}
}
